I am not sure about const_cast in this case. Do we have undefined behaviour or not?
#include <iostream>
#include <vector>
using namespace std;
struct A {
mutable vector<int> a;
A() : a(1,2) {}
const vector<int>& get() const {
return a;
}
};
int main()
{
A a;
vector<int> &b = const_cast<vector<int>&>( a.get() );
b[0] = 3;
cout << a.a[0] << endl;
}