I’d like string representations in my code to start with index 1 (not 0). The paper I’m working from indexes at 1; I’d like to remain consistent with the original description.
At the moment I’m simply initialising strings with an additional space char:
the_string = ' ' + string;
However, it means the_string.length() is inconsistent with the ‘real’ length of the string.
Which alternative workaround (write my own string indexing function, make a mystring class and overload the []operator etc.) generates the least code and what is it?
A short and bad solution is to use a macro expansion to -1 the index.
This is fine if you want to align your solution on paper and code – but never let that code get into any production system.