Description
Except for array types, a compound type ([basic.compound]) is not cv-qualified by the cv-qualifiers (if any) of the types from which it is compounded.
In this document, 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 cvT
, the top-level cv-qualifiers of that type are those denoted by cv.[Example 2: The type corresponding to the type-id
const int&
has no top-level cv-qualifiers. The type corresponding to the type-idvolatile int * const
has the top-level cv-qualifierconst
. For a class typeC
, the type corresponding to the type-idvoid (C::* volatile)(int) const
has the top-level cv-qualifiervolatile
. — end example]
Note : According to [basic.compound]/(1.3) and (1.8), both pointers and pointers to member are compound types.
Activity
jwakely commentedon Oct 15, 2020
There is no contradiction. The first example in p6 is saying that the top-level qualifier on the compound type is
const
, it is not affected by thevolatile
qualifier on the typevolatile int
. The second example is saying that the top-level qualifier on the compound type isvolatile
, it is not affected by theconst
qualifier on the function typevoid (int) const
. Both examples perfectly agree with p2.jabelloc commentedon Oct 15, 2020
Ok I see what you mean. But what does it mean a
volatile
pointer to a member function of typevoid(int)
?jensmaurer commentedon Oct 15, 2020
Exactly that: a pointer-to-member is just some (special) data type, and that type can be volatile-qualified, as-if it were a volatile int.
jwakely commentedon Oct 15, 2020
jwakely commentedon Oct 15, 2020
I really think this kind of thing belongs on StackOverflow. Instead of telling us there's a flaw in the standard, you could ask on StackOverflow why the wording seems contradictory. This could be clarified there, and so could your follow-up question about what the volatile-qualified type means.
jabelloc commentedon Oct 15, 2020
Well if that's what you prefer, definitely I'll stop posting issues here. Thanks for your kind attention. Good luck!
jensmaurer commentedon Oct 15, 2020
"what does it mean"
The same what it means to have a volatile T for any other (scalar) T.