typeof Varieties

Learn the typeof varieties used with templates.

We'll cover the following

In some cases, the generic nature of templates makes it difficult to know or spell out certain types in the template code. The following three special typeof varieties are useful in such cases. Although they are introduced in this chapter, they also work in non-templated code.

typeof(this)

typeof(this) generates the type of the this reference. It works in any struct or class, even outside of member functions:

Get hands-on with 1200+ tech skills courses.