#include <iostream>
using namespace std;

class my_vector {
public:
	double data[6] = {1,2,3,4,5,6};
	double & operator()(size_t i) {
		std::cout<<"Calling non-const ()"<<std::endl;
		return data[i];
	}
	double operator()(size_t i) const {
		std::cout<<"Calling const ()"<<std::endl;
		return data[i];
	}
};

void withConst(const my_vector &v) {
	double vv = v(0);
	std::cout<<"v(0) = "<<vv<<std::endl;
	// v(0) = 4.0; // Does not compile
}

void withNonConst(my_vector &v) {
	v(0) = 4.0;
	double vv = v(0);
	std::cout<<"v(0) = "<<vv<<std::endl;
}

int main() {
	my_vector vec;
	withConst(vec);
	withNonConst(vec);
	return 0;
}