Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Find what you need - explore our website and developer resources
7 December 2022
You have likely heard it before - "no raw for loops, use algorithms instead". In this episode, Jesper will give a few examples of code that became much cleaner when rewritten from raw loops to algorithms.
Further, he will introduce an algorithm library he has written to make it much less painful to write code using algorithms.
Links:
* KDAlgorithms: https://github.com/KDAB/kdalgorithms
* The C++ algorithms https://en.cppreference.com/w/cpp/algorithm
* An interesting talk about algorithms: https://www.youtube.com/watch?v=qH6sSOr-yk8
* 105 algorithms in less than one hour: https://youtu.be/2olsGf6JIkU
* List of compiler support: https://en.cppreference.com/w/cpp/compiler_support
* My spare time photo application: http://kphotoalbum.org
* Episode on implementing the lessthan operator: https://youtu.be/M-w0LV8KlOk?list=PL6CJYn40gN6gf-G-o6syFwGrtq3kItEqI
0:00 Introduction
1:07 Introduction to KDAlgorithms
1:38 The problem with the for_each algorithm
2:53 transform - as a loop
3:28 std::transform
4:25 std::transform in C++20
4:53 std::transform in C++23
5:34 kdalgorithms::transformed
8:00 kdalgorithms::transformed - converting the result type
8:37 kdalgorithms::filtered
11:19 kdalgorithms::all_of
12:11 Feedback please
12:42 Modernizing some old code - understanding the old code.
16:08 Now updating it to algorithms
22:07 A few more notes on KDAlgorithms
The example code showcased in this video is available here:
https://github.com/KDAB/kdabtv/tree/master/Qt-Widgets-and-more/algorithms
All QML tips and tricks videos : https://www.youtube.com/playlist?list=PL6CJYn40gN6jWHP5krsQrVGyYtKh3A3be
All Qt Widgets and more videos:
https://www.youtube.com/playlist?list=PL6CJYn40gN6gf-G-o6syFwGrtq3kItEqI
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Learn Modern C++
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
Learn more