Range Based for loop vs iterator for STL Containers
-
Hi All,
Like to know when to prefer, range based for loop vs iterators for STL Containers.
Any pointers on advantage and disadvantages of both method would be also helpful.
Thanks!
-
range based for loops cannot modify the length of the container. iterators facilitate adding or deleting elements.
-
range based for loops cannot modify the length of the container. iterators facilitate adding or deleting elements.
@Kent-Dorfman : Thanks for the input.
If we are not going to modify the container, then which one provide better performance ? -
@Kent-Dorfman : Thanks for the input.
If we are not going to modify the container, then which one provide better performance ?@Vinoth-Rajendran4 said in Range Based for loop vs iterator for STL Containers:
If we are not going to modify the container, then which one provide better performance ?
not using STL Containers
-
@Vinoth-Rajendran4 said in Range Based for loop vs iterator for STL Containers:
If we are not going to modify the container, then which one provide better performance ?
not using STL Containers
@J-Hilk : for STL Container
-
@J-Hilk : for STL Container
@Vinoth-Rajendran4 the only real way to know is benchmarking it.
-
@Vinoth-Rajendran4 the only real way to know is benchmarking it.
@J-Hilk : Thanks for the test suite link.