Date: Mon, 26 Dec 2022 17:38:35 +0000
Take the following sample code:
struct Monkey {
int &i;
};
int main(void)
{
int num = 5;
Monkey const m{num};
m.i = 7;
}
On the last line there, I'm able to assign to 'i' even though 'm' is const.
I propose that we should be able to determine the CV qualifiers of the
object and re-use them on the member objects, maybe something like:
struct Monkey {
int cvhost &i;
};
So if you have a const object of type 'Monkey', then 'i' is a reference to
const. If you have a non-const volatile object of type 'Monkey', then 'i'
is a reference to volatile. If you have a const volatile object of type
'Monkey', then 'i' is a reference to const volatile.
struct Monkey {
int &i;
};
int main(void)
{
int num = 5;
Monkey const m{num};
m.i = 7;
}
On the last line there, I'm able to assign to 'i' even though 'm' is const.
I propose that we should be able to determine the CV qualifiers of the
object and re-use them on the member objects, maybe something like:
struct Monkey {
int cvhost &i;
};
So if you have a const object of type 'Monkey', then 'i' is a reference to
const. If you have a non-const volatile object of type 'Monkey', then 'i'
is a reference to volatile. If you have a const volatile object of type
'Monkey', then 'i' is a reference to const volatile.
Received on 2022-12-26 17:38:38