jeudi 15 juillet 2021

How to "cut" vector in c++ like python Syntax

in python if I have some iterable can I do something like this:

v = v[n:k] // 
for i in v[3:]:
     "do something"

and now c++ i want to this:

vector<int> v = {1,2,3,4,5,6,7,8}
v = v[3:5]; 

Or something like this:

for(auto n: v[2:end])
       "do something";

I tryed to find the Syntax fro this problem but dident find something yet. thanks for the help!

Aucun commentaire:

Enregistrer un commentaire