Understanding Name Binding and Dependent Names
Learn about name binding and its various categories.
Kinds of names used within templates
The term name binding refers to the process of finding the declaration of each name that is used within a template. There are two kinds of names used within a template: dependent names and nondependent names. The former are names that depend on the type or value of a template parameter that can be a type, non-type, or template parameter. Names that don’t depend on template parameters are called nondependent. The name lookup is performed differently for dependent and nondependent names:
For dependent names, it’s performed at the point of template instantiation.
For nondependent names, it’s performed at the point of the template definition.
We’ll first look at nondependent names. As previously mentioned, name lookup happens at the point of the template definition. This is located immediately before the template definition. To understand how this works, let’s consider the following example:
Get hands-on with 1400+ tech skills courses.