CppCon 2018: Bob Steagall “Fancy Pointers for Fun and Profit”

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


In modern C++ it is possible to implement user-defined types that closely mimic the behavior of ordinary pointers; these types are often referred to as fancy (or synthetic) pointers. With such types at one's disposal, it becomes feasible to build standard-conforming allocators that support relocatable memory in a way that is compatible with the standard containers. This, in turn, enables the use of the standard containers in applications like shared-memory databases, self-contained private heaps, and lightweight object persistence.

This talk will describe a small set of components that implement synthetic pointers. We'll begin by looking briefly at a couple of motivating problems, and then review how the standard defines "pointer-like types". We'll then discuss how closely a user-defined type can emulate ordinary pointers and sketch out a strategy for implementing such a type using the concepts of addressing model, storage model, and pointer interface.

We'll jump into the deep end by implementing two different addressing models, offset addressing and based 2D addressing, which act as policy types for a synthetic pointer class template. We'll then review simple storage models that support raw memory allocation for both addressing models before examining the synthetic pointer class in detail. We'll discuss how the synthetic pointer class interacts with the addressing models to implement pointer operations and emulate an ordinary pointer's interface.

Finally, the talk will provide an example of how these concepts can be applied - namely, containers in a self-contained private heap.

Bob Steagall, KEWB Computing
CppCon Poster Chair

I've been working in C++ since discovering the second edition of The C++ Programming Language in a college bookstore in 1992. The majority of my career has been spent in medical imaging, where I led teams building applications for functional MRI and CT-based cardiac visualization. After a brief detour through the world of DNS and analytics, I'm now working in the area of distributed stream processing. I'm a relatively new member of the C++ Standardization Committee, and launched a blog earlier this year to write about C++ and related topics. I hold BS and MS degrees in Physics, and I'm an avid cyclist when weather permits.

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

I'm more and more impressed by Bob Steagall. I only understood about 30% of the explanation, but the result is very interesting!
One thing I didn't get was, do you always need to write an allocator for your own class or is there a 'one size fits all'? Because it was this exact problem I had when trying to build a game server.

OperationDarkside
Автор

Die deutsche Übersetzung des Videotitels ist katastrophal. Ist es möglich diese zu ändern? "Pointer" als "Hinweise" zu übersetzen macht es selbst dann unmöglich den Titel zu verstehen, wenn man versucht zu raten was wohl der Orginaltitel gewesen sein könnte.

tslivede
Автор

Very advanced talk, we almost need a sub-talk to go over and wrap-up everything he said. Or blog post :p But what I think this is all about is, TLDR: to avoid Serialization / De-Serialization of JSON/XML and instead use fast binary IO or even memcpy to write and read data objects. @8:00

mrlithium
Автор

But all fun in "portable" executable code. I needed it quite long time ago. I.e. I want to be able to memmove blob of instructions without (or with small amount) of extra work, and call it. Of course code itself references own set of global data, but that was actually the easiest part to implement.

yaroslavpanych
Автор

Is there an usable implementation of this in git somewhere?

IllumTheMessage