C++Now 2018 has ended
Back To Schedule
Tuesday, May 8 • 9:00am - 10:30am
Fancy Pointers for Fun and Profit

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
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, based 2D addressing and offset 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. We'll also take a quick look at alternative implementations of the synthetic pointer type.

Finally, the talk will provide a couple examples of how these concepts can be applied - namely, containers in shared memory and self-contained private heaps.

avatar for Bob Steagall

Bob Steagall

CppCon Poster Chair, KEWB Computing
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... Read More →

Tuesday May 8, 2018 9:00am - 10:30am MDT
Flug Auditorium