> I have some example code that runs with iterators passed by reference.
> Is there a time to use references and a time not to?
In general, iterators are expected to be cheaply copyable types.
The general thumb rule is: pass an iterator by reference to non-const if the iterator should be modified by the function (eg. std::advance); otherwise pass iterators by value.
> What does this mean:
> message : A non-const reference may only be bound to an lvalue
Exactly what it says:
1 2
int& r1 = 23 ; // *** error *** : non-const reference may only be bound to an lvalue
constint& r2 = 23 ; // fine; reference to const (lifetime of the temporary is extended)