I Just Wanted to Point to Something!

Description

Every non-trivial programming language needs a way to refer to another object that is stored in a different place. In some programming languages this behavior is the default ­— they have reference semantics.

But this is not the case in C++. In C++ you need a special type to refer to another object: a pointer. I mean a reference … or std::reference_wrapper? Or maybe a smart pointer. But probably std::string_view if the object is a string. And sometimes an iterator if you’re pointing to anything in a container. Or maybe something completely different.

Confused? Maybe not. Maybe you are experienced and know what to choose. But did you always choose correctly? This talk will provide comprehensive guidelines.

We’ll answer questions like:

In the end you’ll know exactly when to use which pointer-like type and why.

Note: I’m much more happy with the version of the talk I gave at C++Now 2018, consider checking it out instead: foonathan.net/cppnow2018.html.

Video


Slides


See Also