Pipes: How Plumbing Can Make Your C++ Code More Expressive - Jonathan Boccara - CppCon 2020

135 Просмотры
Издатель
https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
In code we work with collections of objects all the time, yet it's not always easy to operate on them with concise and expressive code.

Traversing collections with for loops gets ugly and brittle as soon as they have more than a few lines.
STL algorithms are a big step further, but they don't compose well (ever had the need for a "transform_if" algorithm?)
Ranges are another big step further, but like every library they don't cover all cases (Did you know about the transform-filter performance problem? Or that you're not allowed to use rvalues as inputs? Or that you have to use tuples when working on several collections?)

In this talk you will discover pipes, another way to write expressive code to operate with collections: write your code as plumbing through which your data flows.

Like every library pipes also have their limitations, which we will present, but using them as a complement of ranges and STL algorithms will bring you the following benefits:
- An efficient transform-filter
- zip two collections without using tuples
- send data to several outputs
- use rvalues as inputs and as intermediate results
- pick up the data coming out of STL algorithms
- integrate results in destination containers
- pipes are very easy to implement, so you can add new ones

Come see how pipes can improve your code!

---
Jonathan Boccara is a Principal Engineering Lead at Murex where he works on large codebases in C++.
His primary focus is searching how to make code more expressive. He has dedicated his blog, Fluent C++, to writing expressive code in C++.
He also gives internal trainings on C++ every day, in the short format called "Dailies".

---
Streamed & Edited by Digital Medium Ltd - events.digital-medium.co.uk
events@digital-medium.co.uk
Категория
Язык программирования C++
Комментариев нет.