How can I write a 'pass reference by value' wrapper in C++?
<p>I'm writing a compiler for a class, and we've decided to adopt java-like semantics for our variables. Basically, reads behave like pointer dereferences, and writes behave like pointer assignment. </p>

<p>So then, how can I write a wrapper class that has these semantics? Basically, every operator except assignment will be passed to the dereferenced value. </p>

<p>EDIT: This would want to be a template class that wraps a variable of a given type. You assign it a variable, and then use the wrapper in the place of the variable. The aim is that the wrapper containing a pointer to the original variable will have the same semantics as a java variable. </p>

<p>Major clarification: the compiler is translating our language down to C++, and this class is going to be used in the translated code. </p>
