I like STL algorithms, and prefer use algorithms rather than usual loops.
Almost all STL algorithms are usually used as:
std::algorithm_name( container.begin(), container.end(), ..... )
container.begin(), container.end()
- is one of most popular words pair in my projects.
Does anybody have the same problem?
How do you Guys solve this problem?
What could you propose to avoid this duplication? I see a few ways for solution, but all of them have different limitations (macro usage, not compatible with usual pointers, etc.).
Standard Template Library (STL) IV - Algorithms - 2020. The standard algorithms are found in <algorithms>. There are about 60 standard algorithms are defined in <algorithms>.
The Standard Template Library, or STL, is a C++ library of container classes, algorithms, and iterators; it provides many of the basic algorithms and data structures of computer science. The STL is a generic library, meaning that its components are heavily parameterized: almost every component in the STL is a template.
The Standard Template Library (STL) is a set of C++ template classes to provide common programming data structures and functions such as lists, stacks, arrays, etc. It is a library of container classes, algorithms, and iterators. It is a generalized library and so, its components are parameterized.
The next C++ standard, C++0X (where X stands for, hopefully, 9) will add the possibility to change from iterator perspective to container perspective. You will be able to do eg.
std::sort(my_vec);
If you cant wait for this I would recommend you to look at: Boost.Range
And if you are a really interested in iterators/ranges I would recommend you to read Andrei's "iterators must go"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With