- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is "Argument-Dependent Lookup" ("Koenig Lookup") in C++?
Argument-dependent lookup(ADL) is a protocol for looking up unqualified function names in function-call expressions.
These function call expressions include implicit function calls to overloaded operators.
The function names are looked up in the namespaces of their arguments in addition to the scopes and namespaces considered by the usual unqualified name lookup. Argument-dependent lookup makes it possible to use operators defined in a different namespace.
Example
namespace MyNamespace{ class A {}; void f( A &a, int i) {} } int main() { MyNamespace::A a; f( a, 0 ); //calls MyNamespace::f }
The lookup of a function call to f was dependent on the argument a. The same case is applied to arguments like << and >> that are looked up in std namespace when we use things like cout, cin, endl, etc.
Advertisements
To Continue Learning Please Login
Login with Google