[STL] Comment about STL libraries performance
1 unresolved thread
1 unresolved thread
Compare changes
It is important also to highlight that the STL algorithms may be more efficient that any development that may do, but these algorithms are designed in a very generic way, so these methods can be applied to any class in C++. Therefore. the reason for using the standard library algorithms is not to get better efficiency, it is to allow you to think at a higher level of abstraction. While there might be some cases where the algorithm will be faster than your own hand-rolled code, that's not what they're there for. One of the great advantages of C++ is that it allows you to bypass the built-in libraries when you have a specific need. If your benchmarking has shown that the standard library is causing a critical slowdown, you are free to explore classic alternatives such as loop unrolling. For most purposes that will never be necessary.
On top of this, C++ 20 introduce a completely new way to deal with algorithms, which does not rely on direct use of iterators but instead on a range library. This leads to a syntax which is more akin to what is done in other languages - see for instance this example lifted from this [blog post](https://www.modernescpp.com/index.php/c-20-the-ranges-library):
On top of this, C++ 20 introduce a completely new way to deal with algorithms, which does not rely on direct use of iterators but instead on a range library. This leads to a syntax which is more akin to what is done in other languages - see for instance this example lifted from this [blog post](https://www.modernescpp.com/index.php/c-20-the-ranges-library):