I Just Wanted to Point to Something!

By Jonathan Müller

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:

  • When should I use a reference, when a pointer, when something different?

  • If references are non-null pointers, what’s the point of gsl::non_null<T*> to create a non-null pointer?

  • Do I need std::optional<T&>? Or is it just a pointer?

  • What the heck is C++17’s std::byte* and when is it useful?

  • Is there still a need for void*?

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





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.