std :: distance没有给出预期的输出

尽管每个循环中有一个自变量,std :: distance在for循环中仍返回相同的值。

#include <vector>
#include <iostream>

using namespace std;

int main() {
    vector<int> q{1, 2, 3, 4, 5};
    for (auto i = q.rbegin(); i != q.rend(); i++) {
        static int index_dif = distance(i, q.rend());
        cout << *i << ": " << index_dif << endl;
    }
    return 0;
}

输出是

5: 5
4: 5
3: 5
2: 5
1: 5

Despite the fact that i increments on each loop, so I would expect the distance between q.rend() and it to shrink as the loop progresses, like so:

5: 5
4: 4
3: 3
2: 2
1: 1

Instead it seems to be giving the distance between q.rbegin() and q.rend() every time.