[basic.type.qualifier]

# 6 Basics [[basic]](./#basic)

## 6.9 Types [[basic.types]](basic.types#basic.type.qualifier)

### 6.9.5 CV-qualifiers [basic.type.qualifier]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L5991)

Each type other than a function or reference type
is part of a group of four distinct, but related, types:
a [*cv-unqualified*](#def:cv-unqualified "6.9.5 CV-qualifiers [basic.type.qualifier]") version,
a [*const-qualified*](#def:const-qualified "6.9.5 CV-qualifiers [basic.type.qualifier]") version,
a [*volatile-qualified*](#def:volatile-qualified "6.9.5 CV-qualifiers [basic.type.qualifier]") version, and
a [*const-volatile-qualified*](#def:const-volatile-qualified "6.9.5 CV-qualifiers [basic.type.qualifier]") version[.](#1.sentence-1)

The types in each such group shall have
the same representation and alignment requirements ([[basic.align]](basic.align "6.8.3 Alignment"))[.](#1.sentence-2)[34](#footnote-34 "The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and non-static data members of unions.")

A function or reference type is always cv-unqualified[.](#1.sentence-3)

- [(1.1)](#1.1)

  A [*const object*](#def:object,const "6.9.5 CV-qualifiers [basic.type.qualifier]") is an object of type const T or a
 non-mutable subobject of a const object[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  A [*volatile object*](#def:object,volatile "6.9.5 CV-qualifiers [basic.type.qualifier]") is an object of type volatile T or a subobject of a volatile object[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  A [*const volatile object*](#def:object,const_volatile "6.9.5 CV-qualifiers [basic.type.qualifier]") is an object of type const volatile T, a non-mutable subobject of a const volatile object,
 a const subobject of a volatile object, or a non-mutable volatile
 subobject of a const object[.](#1.3.sentence-1)

[*Note [1](#note-1)*:

The type of an object ([[intro.object]](intro.object "6.8.2 Object model")) includes
the [*cv-qualifier*](dcl.decl.general#nt:cv-qualifier "9.3.1 General [dcl.decl.general]")*s* specified in the[*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1 General [dcl.spec.general]") ([[dcl.spec]](dcl.spec "9.2 Specifiers")),[*declarator*](dcl.decl.general#nt:declarator "9.3.1 General [dcl.decl.general]") ([[dcl.decl]](dcl.decl "9.3 Declarators")),[*type-id*](dcl.name#nt:type-id "9.3.2 Type names [dcl.name]") ([[dcl.name]](dcl.name "9.3.2 Type names")), or[*new-type-id*](expr.new#nt:new-type-id "7.6.2.8 New [expr.new]") ([[expr.new]](expr.new "7.6.2.8 New"))
when the object is created[.](#1.sentence-4)

â *end note*]

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L6033)

Except for array types, a compound type ([[basic.compound]](basic.compound "6.9.4 Compound types")) is not cv-qualified by the
cv-qualifiers (if any) of the types from which it is compounded[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L6037)

An array type whose elements are cv-qualified
is also considered to have the same cv-qualifications
as its elements[.](#3.sentence-1)

[*Note [2](#note-2)*:

Cv-qualifiers applied to an array
type attach to the underlying element type, so the notation
âcv Tâ, where T is an array type, refers to
an array whose elements are so-qualified ([[dcl.array]](dcl.array "9.3.4.5 Arrays"))[.](#3.sentence-2)

â *end note*]

[*Example [1](#example-1)*: typedef char CA[5];typedef const char CC;
CC arr1[5] = { 0 };const CA arr2 = { 0 };

The type of both arr1 and arr2 is âarray of 5const charâ, and the array type is considered to be
const-qualified[.](#3.sentence-3)

â *end example*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L6061)

[*Note [3](#note-3)*:

See [[dcl.fct]](dcl.fct "9.3.4.6 Functions") and [[over.match.funcs]](over.match.funcs "12.2.2 Candidate functions and argument lists") regarding function
types that have [*cv-qualifier*](dcl.decl.general#nt:cv-qualifier "9.3.1 General [dcl.decl.general]")*s*[.](#4.sentence-1)

â *end note*]

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L6067)

There is a partial ordering on cv-qualifiers, so that a type can be
said to be [*more cv-qualified*](#def:more_cv-qualified "6.9.5 CV-qualifiers [basic.type.qualifier]") than another[.](#5.sentence-1)

Table [16](#tab:basic.type.qualifier.rel "Table 16: Relations on const and volatile") shows the relations that
constitute this ordering[.](#5.sentence-2)

Table [16](#tab:basic.type.qualifier.rel) — Relations on const and volatile [[tab:basic.type.qualifier.rel]](./tab:basic.type.qualifier.rel)  

| [ð](#tab:basic.type.qualifier.rel-row-1)<br>*no cv-qualifier* | < | const |
| --- | --- | --- |
| [ð](#tab:basic.type.qualifier.rel-row-2)<br>*no cv-qualifier* | < | volatile |
| [ð](#tab:basic.type.qualifier.rel-row-3)<br>*no cv-qualifier* | < | const volatile |
| [ð](#tab:basic.type.qualifier.rel-row-4)<br>const | < | const volatile |
| [ð](#tab:basic.type.qualifier.rel-row-5)<br>volatile | < | const volatile |

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L6083)

In this document, the notation cv (or*cv1*, *cv2*, etc[.](#6.sentence-1))

, 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[.](#6.sentence-2)

For a type cv T, the [*top-level cv-qualifiers*](#def:cv-qualifier,top-level "6.9.5 CV-qualifiers [basic.type.qualifier]") of that type are those denoted by cv[.](#6.sentence-3)

[*Example [2](#example-2)*:

The type corresponding to the [*type-id*](dcl.name#nt:type-id "9.3.2 Type names [dcl.name]")const int& has no top-level cv-qualifiers[.](#6.sentence-4)

The type corresponding to the [*type-id*](dcl.name#nt:type-id "9.3.2 Type names [dcl.name]")volatile int * const has the top-level cv-qualifier const[.](#6.sentence-5)

For a class type C,
the type corresponding to the [*type-id*](dcl.name#nt:type-id "9.3.2 Type names [dcl.name]")void (C​::​* volatile)(int) const has the top-level cv-qualifier volatile[.](#6.sentence-6)

â *end example*]

[34)](#footnote-34)[34)](#footnoteref-34)

The same representation and alignment requirements
are meant to imply interchangeability as
arguments to functions,
return values from functions, and
non-static data members of unions[.](#footnote-34.sentence-1)
