C++ Russia 2021
Fun with type erasure
+ dispatching data from abstract structure to function parameters
Sometimes we want some kind of magic that would call the appropriate handler for a request, and put appropriate request fields into function parameters, e.g.:
{
"request": "baz",
"count": 1,
"id": "two",
"payload": { "three": 3 }
}
↓
public class Program
{
public static void foo()
{ }
public static void bar([Name("count")] int i)
{ }
public static void baz([Name("count")] int i,
[Name("id")] string s,
[Name("payload")] JsonElement p)
{ }
}
We want this magic more when the number of handlers with many parameters grows significantly.
In this talk, we will concentrate on type erasure to make a convenient and user-friendly way of organizing request handlers.
We will examine several approaches, their profit, how we can make it better, and what else we can do with it. Warning: there will be a lot of code.
Demos are here.
Video: https://www.youtube.com/
Description on the conference site:
https://2021.cppconf.ru/
(and in Russian)
Slides: