unique_pseudofunction: N overloads for the price of 1 - Filipp Gelman - CppCon 2019
Автор: CppCon
Загружено: 2019-10-15
Просмотров: 1728
http://CppCon.org
—
Discussion & Comments: / cpp
—
Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2019
—
This talk will present a class template that behaves almost like `unique_function`, but lacks one of its key restrictions: having just one overload of `operator()`.
`std::function` is an excellent tool for interface design. It encapsulates almost any object that is invocable the right way. `unique_function` is an even better tool. It can encapsulate some types that `std::function` can't - the ones that are move-only. Unfortunately, it is still invocable in just one way. You get one list of argument types and that's what you must pass.
What if the object you want to pass is invocable in more than one way? What if its `operator()` is a template that you will instantiate with N different types? What if it is a variadic template to which you will pass 0-N arguments? What if you use tag dispatch to do N different things?
If you want these things, as well as the type erasure offered by `std::function` and the move-only support offered by `unique_function`, then `unique_pseudofunction` is the class for you.
Follow the path I took towards realizing that `unique_pseudofunction` is the solution to most of my problems. We'll break this down into the following steps:
Building a simple non-generic `unique_function`
Making it generic
Adding a small buffer optimization
Extending it to support more than one overload of `operator()`
We will also look in close detail at several problems solved along the way, and several others that are still unsolved.
This talk involves small amounts of C++17 and large amounts of template metaprogramming, function references, and type erasure.
—
Filipp Gelman
Software Developer, Bloomberg LP
At Bloomberg LP since 2016, Filipp enjoys exploring the obscure, arcane, and esoteric corners of the C++ language. He is known among his coworkers for heavy use of templates, emphasis on compile time computation, and abusing language features for nefarious purposes.
—
Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
*-----*
Register Now For CppCon 2022: https://cppcon.org/registration/
*-----*
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: