· 01:15
Welcome to C++ Basics. I’m your host. Today we’re diving into how the compiler finds symbols in your code—what the article calls “name lookup.” There are three kinds: qualified name lookup, unqualified name lookup, and Argument-Dependent Lookup, or ADL.
First, qualified name lookup handles symbols explicitly scoped with ::. As the author puts it, it “only searches the explicitly named scope,” so a::b::x finds x in a::b and ignores a::w or anything outside.
Next, unqualified name lookup applies to plain identifiers. It “starts in the innermost scope and proceeds outward,” checking local variables, class members, enclosing namespaces, and finally the global scope or any using directives.
Finally, ADL lets the compiler find functions based on their argument types. For example, calling normalize(a) finds math::normalize because a is a math::Vec. Remember, ADL only works for functions, not types.
That’s name lookup in C++ in a nutshell. Thanks for listening!
Link to Article
Listen to jawbreaker.io using one of many popular podcasting apps or directories.