I'm having a hard time figuring out how to return a non-const reference to an element in a std::vector from a const class method. A simple example of what I'm going for is,
template<class T>
class MyClass
{
 public:
 MyClass : myVec(3)
 {
 }
 T& x() const
 {
    return *(myVec.data())[0]
 }
 std::vector<T> myVec;
}
The behavior I'm going for is that I'd like to be able to do things like the following,
MyClass obj<double>;
obj.x() = 3.3;
assert(obj.x()==3.3)
Eigen gives the same type of behavior, but I've not been able to figure out how to get it to work.
 
     
    