In C++, I can add cv-qualifiers to a reference:
int main()
{
int i = 5;
const volatile int & ri = i;
}
but not remove cv-qualifiers:
int main()
{
const volatile int i = 5;
int & ri = i;
}
Where in the standard is that defined (both, adding is allowed and removing is not allowed)?
I found a definition of "more cv-qualified" in C++23 N4928 §6.8.5 (5), [basic.type.qualifier] or on eel.is.
I then searched for usages of "more cv-qualified", but none of them seems to match references:
The standard uses "reference-compatible with" instead of "more/less cv-qualified" for reference initialization.
This is described by [dcl.init.ref]/4
and [dcl.init.ref]/5
.
The definition of "reference-compatible" boils down to is the same conversion legal for pointers, which is in turn defined in [conv.qual]/3
.