I don't understand what you mean for the "const case" because the point of const is that assignements aren't allowed.
For the non-const case, you can add a reference on the global variable and so use the reference to modify the variable.
However it's not recommended to use global variables for multiples reasons, so maybe you can copy your code here and explain what's the point of this so we can help you to find another better solution.