ClickHouse is a column-oriented DBMS. In it, data processing pipeline works with parts of columns — medium-sized arrays of homogeneous data. Concerning these objects, it would be logical to manage resources through std::shared_ptr or intrusive pointer with reference count. And the option to divide ownership is very convenient for implementing common subexpression elimination in the queries.
But reality showed that shared_ptr was not safe enough. So we had to invent a new kind of pointer which could be used to carefully manage object modifications. In this talk, we'll cover the mechanics of implementing these pointers, details of how they can be used for complex data structures, and examples of the capabilities of modern C++ which are necessary for the implementation. We'll also discuss several capabilities modern C++ is missing — they could make the implementation easier.