What's is cv-qualified type?

6 views
Skip to first unread message

nacc...@gmail.com

unread,
Nov 4, 2005, 6:08:38 AM11/4/05
to
Hi guys

Can everyone tells me what's the meaning of cv-qualified type? I've
seen the word many times and got confused with it. Many thanks!


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Zara

unread,
Nov 5, 2005, 6:30:59 AM11/5/05
to
On 4 Nov 2005 06:08:38 -0500, nacc...@gmail.com wrote:

>Hi guys
>
>Can everyone tells me what's the meaning of cv-qualified type? I've
>seen the word many times and got confused with it. Many thanks!
>
>

A cv-qualified type is a type thta nave been qulified either as const
or volatile, i.e.

// non cv_qualified

int first;
char *second;

// cv-qualified
const int third;
volatile char * fourth;

Regards
-- Zara

Rob

unread,
Nov 5, 2005, 6:33:59 AM11/5/05
to
nacc...@gmail.com wrote:

> Hi guys
>
> Can everyone tells me what's the meaning of cv-qualified type? I've
> seen the word many times and got confused with it. Many thanks!
>
>

cv qualified means const- or volatile- qualified.

Essentially a cv qualified type is a type that is qualified by const,
volatile, or both.

Peter Steiner

unread,
Nov 5, 2005, 6:34:57 AM11/5/05
to
a cv-qualified type is the "const", "volatile" or "const volatile"
version of a type. that is, a variable, function, etc. declared without
one of those is cv-unqualified, while the addition of one of those
specifies a cv-qualified type.

see standard 3.9.3 "CV-qualifiers" for more details...

Ben Hutchings

unread,
Nov 5, 2005, 6:42:03 AM11/5/05
to
<nacc...@gmail.com> wrote:
> Hi guys
>
> Can everyone tells me what's the meaning of cv-qualified type? I've
> seen the word many times and got confused with it. Many thanks!

"cv-qualified" is an abbreviation for "const- and/or volatile-
qualified". A cv-qualified type is a type that has const and/or
volatile at its top level, e.g. const int.

--
Ben Hutchings
Having problems with C++ templates? Your questions may be answered by
<http://womble.decadentplace.org.uk/c++/template-faq.html>.

werasm

unread,
Nov 5, 2005, 7:36:01 AM11/5/05
to

nacc...@gmail.com wrote:
> Hi guys
>
> Can everyone tells me what's the meaning of cv-qualified type? I've
> seen the word many times and got confused with it. Many thanks!
Hi,

An obvious guess would be constant/volatile qualifier. Although section
3.9.3 (c++98) explains cv-qualifiers in detail, they don't explicitly
state CV to be const/volatile - I suspect it is too obvious. Anyone
please correct me if I'm wrong. BTW, I have not seen this question in
the C++ FAQ's. Is their an acronym section?

Werner

Thomas Maeder

unread,
Nov 5, 2005, 7:36:42 AM11/5/05
to
nacc...@gmail.com writes:

> Can everyone tells me what's the meaning of cv-qualified type? I've
> seen the word many times and got confused with it. Many thanks!

c and v stand for const and volatile. So any type qualified with
volatile and/or const ist cv-qualified.

ric...@ex-parrot.com

unread,
Nov 5, 2005, 7:34:09 AM11/5/05
to
It's a type that might be const or volatile or both. So the following
are all cv-qualified int types:

int
int const
int volatile
int const volatile

--
Richard Smith

Martin Bonner

unread,
Nov 5, 2005, 7:33:34 AM11/5/05
to

nacc...@gmail.com wrote:
> Hi guys
>
> Can everyone tells me what's the meaning of cv-qualified type? I've
> seen the word many times and got confused with it. Many thanks!

See section 3.9.3 of the standard. I quote:
"3.9.3 CVqualifiers [basic.type.qualifier]
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."

So "int" is cv-unqualified. "const int" and "volatile int" are
cv-qualified versions of the same type.

Dan McLeran

unread,
Nov 5, 2005, 7:30:54 AM11/5/05
to
cv = const volatile. If you've got it, check out the standard section
3.9.3.

Paul Floyd

unread,
Nov 5, 2005, 1:30:12 PM11/5/05
to
On 4 Nov 2005 06:08:38 -0500, nacc...@gmail.com <nacc...@gmail.com> wrote:
> Hi guys
>
> Can everyone tells me what's the meaning of cv-qualified type? I've
> seen the word many times and got confused with it. Many thanks!

It means that the type is qualified with const and/or volatile.

A bientot
Paul
--
Paul Floyd http://paulf.free.fr (for what it's worth)
Surgery: ennobled Gerald.

albrecht.fritzsche

unread,
Nov 7, 2005, 5:50:32 AM11/7/05
to
ric...@ex-parrot.com wrote:
> It's a type that might be const or volatile or both. So the following
> are all cv-qualified int types:
>
> int
> int const
> int volatile
> int const volatile

Even the very first one? I don't think so.

Ali

Francis Glassborow

unread,
Nov 7, 2005, 4:14:01 PM11/7/05
to
In article <436efbae$0$7430$9b4e...@newsread4.arcor-online.net>,
albrecht.fritzsche <albrecht....@arcor.de> writes

>ric...@ex-parrot.com wrote:
>> It's a type that might be const or volatile or both. So the following
>> are all cv-qualified int types:
>>
>> int
>> int const
>> int volatile
>> int const volatile
>
>Even the very first one? I don't think so.

Yes, definitely including the first one. These days we consider zero to
be a number with equal status to 1, 2 etc. In the same way no use of
const/volatile is a legitimate form of qualification. Without that
understanding the wording of several parts of the Standard would become
even more convoluted.

--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects

Alberto Ganesh Barbati

unread,
Nov 8, 2005, 5:40:33 AM11/8/05
to
Francis Glassborow wrote:
> In article <436efbae$0$7430$9b4e...@newsread4.arcor-online.net>,
> albrecht.fritzsche <albrecht....@arcor.de> writes
>
>>ric...@ex-parrot.com wrote:
>>
>>>It's a type that might be const or volatile or both. So the following
>>>are all cv-qualified int types:
>>>
>>> int
>>> int const
>>> int volatile
>>> int const volatile
>>
>>Even the very first one? I don't think so.
>
>
> Yes, definitely including the first one. These days we consider zero to
> be a number with equal status to 1, 2 etc. In the same way no use of
> const/volatile is a legitimate form of qualification. Without that
> understanding the wording of several parts of the Standard would become
> even more convoluted.
>

I understand your point, but 3.9.3/1 is very clear about this:

"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. [...]"

so definitely "int" is not cv-qualified. Am I missing something?

Ganesh

albrecht.fritzsche

unread,
Nov 8, 2005, 5:50:22 AM11/8/05
to
Francis Glassborow wrote:
> In article <436efbae$0$7430$9b4e...@newsread4.arcor-online.net>,
> albrecht.fritzsche <albrecht....@arcor.de> writes
>
>>ric...@ex-parrot.com wrote:
>>
>>>It's a type that might be const or volatile or both. So the following
>>>are all cv-qualified int types:
>>>
>>> int
>>> int const
>>> int volatile
>>> int const volatile
>>
>>Even the very first one? I don't think so.
>
>
> Yes, definitely including the first one. These days we consider zero to
> be a number with equal status to 1, 2 etc.

Ok, now I am confused

[0] int
[1] int const
...

So, including the zero-th one?

;-)

> In the same way no use of
> const/volatile is a legitimate form of qualification. Without that
> understanding the wording of several parts of the Standard would become
> even more convoluted.

Then I am wondering what this term is good for, or to put the
question differently: which type is (according to such a definition)
not cv-qualified?

Ali

Martin Bonner

unread,
Nov 8, 2005, 6:11:42 AM11/8/05
to

Francis Glassborow wrote:
> In article <436efbae$0$7430$9b4e...@newsread4.arcor-online.net>,
> albrecht.fritzsche <albrecht....@arcor.de> writes
> >ric...@ex-parrot.com wrote:
> >> It's a type that might be const or volatile or both. So the following
> >> are all cv-qualified int types:
> >>
> >> int
> >> int const
> >> int volatile
> >> int const volatile
> >
> >Even the very first one? I don't think so.
>
> Yes, definitely including the first one.
That's not what 3.9.3/1 in the standard says. It is quite clear that
plain int is a cv-unqualified type, and the following three are
cv-qualified types.

Note that 3.9.3/5 does say "the notation <i>cv</i> ... represents an
arbitrary set of cvqualifiers ... [including] the empty set."

Niklas Matthies

unread,
Nov 8, 2005, 6:58:46 AM11/8/05
to
On 2005-11-07 21:14, Francis Glassborow wrote:
> albrecht.fritzsche <albrecht....@arcor.de> writes:
>>ric...@ex-parrot.com wrote:
>>> It's a type that might be const or volatile or both. So the
>>> following are all cv-qualified int types:
>>>
>>> int
>>> int const
>>> int volatile
>>> int const volatile
>>
>>Even the very first one? I don't think so.
>
> Yes, definitely including the first one.

No, the standard calls the first one cv-unqualified. From 3.9.3p1:

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 [...] The cv-qualified or cv-unqualified versions of a
type are distinct types; [...]

Also in example 7.1.5.1p5 there is the following line:

int i = 2; // not cv-qualified

All this makes it pretty clear that "cv-qualified type" in the
standard does not include the cv-unqualified versions.

What you may be thinking of is the notation "cv T", for which the
standard says (3.9.3p5):

In this International Standard, the notation /cv/ (or /cv1/, /cv2/,
etc.), used in the descriptions of types, represents an arbitrary
set of cv-qualifiers, i.e., one of {const}, {volatile}, {const,
volatile}, or the empty set.

Here the "cv" includes the cv-unqualified version.

-- Niklas Matthies

Francis Glassborow

unread,
Nov 8, 2005, 9:52:00 AM11/8/05
to
In article <pzRbf.51178$Pe2.9...@twister2.libero.it>, Alberto Ganesh
Barbati <Alberto...@libero.it> writes
No you aren't, I was. However I am far from convinced that the
terminology as defined in 3.9.3/1 is helpful.

Not least because we finish up with potential confusion when dealing
with typedefs where we have to know whether the type provided by the
typedef has either or both of const and volatile as qualifiers.

I think the problem arises because the Standard needs to write about
unqualified types and so elects to provide a dichotomy between qualified
and unqualified rather than make unqualified a subset of the 'qualified'
types.

In the long run this probably does not matter.

The point I was making (badly) is that in most circumstances we consider
all four bit patterns 00, 01, 10, 11 as providing a set of properties,
and we do not normally exclude 00 if the 'object' being considered can
exist with neither property.

Anyway, as this is not comp.std.c++ perhaps we have aired this enough.


--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects

Francis Glassborow

unread,
Nov 8, 2005, 1:16:22 PM11/8/05
to
In article <43704a33$0$21943$9b4e...@newsread2.arcor-online.net>,
albrecht.fritzsche <albrecht....@arcor.de> writes

>Then I am wondering what this term is good for, or to put the
>question differently: which type is (according to such a definition)
>not cv-qualified?

It is perfectly possible to define cv-qualified types so the include
those that are neither const not volatile as a subset. (We normally
consider black a colour, even though a physicist would say that black is
a state of the absence of colour)


--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects

kanze

unread,
Nov 8, 2005, 11:33:32 PM11/8/05
to

> >>ric...@ex-parrot.com wrote:

> ;-)

Consider:

int i = 3 ;

The expression 'i' is an lvalue with a cv_qualified type. The
expression '3' has a non cv_qualified type.

That's the way I understand it, anyway.

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Niklas Matthies

unread,
Nov 8, 2005, 11:35:30 PM11/8/05
to
On 2005-11-08 18:16, Francis Glassborow wrote:
> albrecht.fritzsche <albrecht....@arcor.de> writes
>>Then I am wondering what this term is good for, or to put the
>>question differently: which type is (according to such a definition)
>>not cv-qualified?
>
> It is perfectly possible to define cv-qualified types so the include
> those that are neither const not volatile as a subset.

But then saying "T is a cv-qualified type" would be the same as just
saying "T is a type". The term would then be useless for qualifying
(no pun intended) types.

-- Niklas Matthies

kanze

unread,
Nov 8, 2005, 11:33:03 PM11/8/05
to

> >>>ric...@ex-parrot.com wrote:

I think the problem arises because there are contexts where
cv_qualification doesn't matter, and is irrelevant or
non-existant, and others where it does. Where it does matter,
"int" is in opposition to the other three, and like you, I would
consider it a cv_qualified type. On the other hand, an
expression like 3 has type int, and is not cv_qualified
(although it is definitly constant, in the everyday sense).

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

albrecht.fritzsche

unread,
Nov 9, 2005, 9:23:20 AM11/9/05
to
Francis Glassborow wrote:
> In article <43704a33$0$21943$9b4e...@newsread2.arcor-online.net>,
> albrecht.fritzsche <albrecht....@arcor.de> writes
>
>>Then I am wondering what this term is good for, or to put the
>>question differently: which type is (according to such a definition)
>>not cv-qualified?
>
>
> It is perfectly possible to define cv-qualified types so the include
> those that are neither const not volatile as a subset.

Not sure if I understand this - has this sentence the same meaning
as something along the lines

"It is perfectly possible to define cv-qualified types such that they
include those that are neither const nor volatile as a subset."

Then again my question - what is this term good for?

Since I now have looked into the standard - 3.9.3 starts with

"A type mentioned in 3.9.1 [Fundamental types] and 3.9.2
[Compound types] is a /cv-unqualified type/."

Would you know agree that int is *not* a cv-qualified type? If not,
then please read on in the cited paragraph.

Ali

Niklas Matthies

unread,
Nov 9, 2005, 9:00:12 PM11/9/05
to
On 2005-11-09 04:33, kanze wrote:
> albrecht.fritzsche wrote:
:

>> Then I am wondering what this term is good for, or to put the
>> question differently: which type is (according to such a
>> definition) not cv-qualified?
>
> Consider:
>
> int i = 3 ;
>
> The expression 'i' is an lvalue with a cv_qualified type. The
> expression '3' has a non cv_qualified type.

Both expressions have exactly the same type, which is 'int'.
You're probably referring to the fact that non-class rvalues are
always cv-unqualified. But lvalueness is a property of expressions,
not of types, thus I see no justification to let it decide when a
type should be considered "cv-qualified" or not.

-- Niklas Matthies

Allan W

unread,
Nov 10, 2005, 3:26:36 PM11/10/05
to
> > albrecht.fritzsche <albrecht....@arcor.de> writes
> >>Then I am wondering what [the term cv-qualified] is good for, or to

> >>put the question differently: which type is (according to such a
> >>definition) not cv-qualified?

> Francis Glassborow wrote:
> > It is perfectly possible to define cv-qualified types so the include
> > those that are neither const not volatile as a subset.

albrecht.fritzsche wrote:
> Not sure if I understand this - has this sentence the same meaning
> as something along the lines
>
> "It is perfectly possible to define cv-qualified types such that they
> include those that are neither const nor volatile as a subset."
>
> Then again my question - what is this term good for?
>
> Since I now have looked into the standard - 3.9.3 starts with
>
> "A type mentioned in 3.9.1 [Fundamental types] and 3.9.2
> [Compound types] is a /cv-unqualified type/."
>
> Would you know agree that int is *not* a cv-qualified type? If not,
> then please read on in the cited paragraph.

I won't pretend to be an expert on the standard, but it seems to me
that we could use the term cv-qualified to compare with cv-unqualified
types.

- "X is a cv-qualified type" means that it might (but does not need
to) have const and/or volatile qualifiers.
- "X is a cv-unqualified type" means that it must not have const
and/or volatile qualifiers.

On the other hand, if we said something like "if X is cv-qualified..."
we're saying "if it has const or volatile qualifiers (or both)..."

I don't know if this is right, but it at least makes sense.

Reply all
Reply to author
Forward
0 new messages