In C++20 you can utilize views::reverse found in ranges library and supported by gcc 10.
#include
#include
#include
int main()
{
std::vector V{0, 1, 2, 3, 4, 5, 6, 7};
for (auto v : V | std::views::reverse)
{
std::cout << v << " ";
}
return 0;
}
And the output is:
7 6 5 4 3 2 1 0