Abdelrazak Younes wrote:
enpos is a size_t, do you really think there is a benefit to make it
const? I believe you and I made the change but I'd really like to know
the benefits... And by the way, why not startpos?
startpos too :)
Everything that you can make const should be const. It's not a compiler
optimization thing really. It's really "a document your code so that others
can see what you mean" and a "help the compiler to help you from making
stupid mistakes" thing.
Once you get used to it, it'll become second nature. One especially nice
thing to do is:
foo.h:
#ifndef FOO_H
#define FOO_H
void myFunc(int a);
#endif
foo.C:
#include <config.h>
#include "foo.h"
void myFunc(int const a) {
...
}
Ie, you pass the int by value so it's no concern to your user what you do
with the "a". However, in the implementation, you're telling yourself that
you're not going to be modifying "a".
And the magic is that the compiler will understand and accept your code :)
Angus