Use a pointer instead of ref in state_iterator

Using a reference makes the object non-copyable (at least under libc++), so
switch to a pointer.