When a C++ compiler encounters an expression like f(x, y), it must consider several language mechanisms to decide which function f the program will call. These mechanisms include name lookup, overload resolution, default function arguments, and template processing. Having a firm understanding of these mechanisms and how they interact will help you write user-friendly interfaces for you and your team.
This session begins by reviewing each of these mechanisms individually. It then examines how those mechanisms interact, focusing on situations that are most likely to occur in practice. Some of the questions that we’ll consider are:
- How does the compiler resolve calls on overloaded functions with implicit conversions on multiple arguments?
- Why does the compiler apply implicit conversions when resolving calls to overloaded functions, but not when making calls to function templates?>/li>
After this session, you’ll have a clearer understanding of how the compiler makes sense out of your code. With this knowledge, you’ll find it easier to craft interfaces that are easy to use correctly and hard to use incorrectly. You’ll also be better able to steer the compiler in your intended direction when necessary.