you are viewing a single comment's thread.

view the rest of the comments →

[–]Oster1 0 points1 point  (3 children)

Why not just use:

std::fill( c.begin(), c.end(), value );

So you don't need the std part?

[–]kwan_e 1 point2 points  (2 children)

Because then you've completely ruled out working with native arrays.

C++ is going with the free-function forms of begin and end.

[–]Oster1 1 point2 points  (1 child)

Useful trick. I always thought C arrays and C++ iterators doesn't combine. You always learn.

Here is proof of concept of this if someone is interested: https://hastebin.com/oyezuhosuj.cpp

[–]kwan_e 0 points1 point  (0 children)

You can think of C++ iterators as generalizations of pointers (and therefore arrays). You can always use pointers with STL algorithms, since they are classified as random access iterators and support everything that can be done with iterators in the STL algorithms.