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.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals