In C ++, you can now have members mutable. This adds a “logical const” layer to the language. How do they relate to read-only data - will it have an element mutableto prevent the const class from being placed in the section .rodata?
class Foo {
mutable int bar;
public:
Foo(): bar(0) {}
void set(int x) const { bar = x; }
};
const Foo foo;
int main(void)
{
foo.set(5);
}
source
share