C++ Templates: Two-Phase Lookup

Amir Kirsh

⏱ 20 mins
beginner
intermediate
advanced
14:00-14:30, Friday, 19th June 2026 in const west

Nearly 30 years after the rules were set in C++98, even advanced developers still trip over templates' internal name lookup. Why does calling a base function sometimes fail inside templates? And how does adding Base<T>::, or even this->, suddenly fix it?

The answer is two-phase name lookup: non-dependent names are resolved at definition time, while dependent names are resolved at instantiation time.

In this talk, we will walk through the complete timeline of name resolution in templates: non-dependent lookup at parse time, argument deduction at point of use, and dependent lookup during instantiation. You will see concrete examples of what can go wrong if you don't pay attention to the rules, and the simple way of doing things right. This talk will help you avoid pitfalls and obscure bugs and gain better control over your templates instead of relying on "trial and error" coding or the "it just works" approach (which, especially with generic code, may actually push bugs into production).


🏷 Templates
🏷 Foundations

Amir Kirsh

Amir Kirsh is a C++ lecturer at the Academic College of Tel-Aviv-Yaffo and Tel-Aviv University, previously the Chief Programmer at Comverse, after being CTO and VP R&D at a startup acquired by Comverse. He is also a co-organizer of the annual Core C++ conference and a trainer and consultant for C++ and SW development in general.