CppCon 2017: Alfred Bratterud “Delegate this! Designing with delegates in modern C++”

preview_player
Показать описание


Designing a fast IP stack from scratch is hard. Using delegates made it all easier for IncludeOS, the open source library operating system written from scratch in modern C++. Our header-only delegates are just as fast as C-style function pointers, compatible with std::function, and allows any object to delegate work to stateful member functions without knowing anything about the class they belong to. We use delegates for everything from routing packets to creating REST endpoints, and most importantly to tie the whole IP stack together. In this talk we’ll show you how we use delegates in IncludeOS, discuss pitfalls and alternatives, and give you all you need to get started.

Alfred Bratterud: IncludeOS, CTO

Alfred Bratterud is the creator of IncludeOS, the C++ unikernel. The work on IncludeOS started as a PhD research project but has since evolved into a full time venture for the IncludeOS developer team. Alfred holds BSc and MSc in computer science from the University of Oslo, with focus on logic and computability. He has 10+ years of industrial programming experience.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

I really enjoy your talks. Thank you very much.
Let me to correct you at 8:40. Yeah, you can not reassign . But not because funcc is constant. Actually funcc is not constant. The true reason is that for the same lamda expression compiler generates different closure types. For example, `auto f1([] {}); auto f2([] {})`, f1 and f2 have entirely different types (the types are not std::function). So, you can't assign them each to other. Quote from cppreference: "The lambda expression is a prvalue expression of unique unnamed non-union non-aggregate class type, known as closure type...".

ntrandafil
Автор

What is he yapping about at 17:00? Of course you can assign the result of a std::bind() to a std::function<>, als long as the signature is compatible with the callable object that std::bind returns. He probably messed up his placeholders (like using _2 to refer to the first parameter instead of _1, just because it goes into the second slot)

oisyn
Автор

3:30 what do you mean std::function can't point to member functions? Without std::bind you mean?

minciNashu
Автор

google. lol the absolute state of world.

jesuschrist