May be we should change the type of `i` to avoid invoking `static_cast`.