You could use std::generate
to create a vector {0, 1, ..., 999}
std::vector<int> v(1000);
std::generate(v.begin(), v.end(), [n = 0] () mutable { return n++; });
There is an overload that accepts an ExecutionPolicy
so you could modify the above to
std::vector<int> v(1000);
std::generate(std::execution::par, v.begin(), v.end(), [n = 0] () mutable { return n++; });
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…