
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.
- Related Questions & Answers
- What is the difference between "std::endl" and "\n" in C++?
- "static const" vs "#define" vs "enum" ?
- Month ("M", "m") Format Specifier in C#
- What is the difference between "var" and "val" in Kotlin?
- What is the difference between "const" and "val" in Kotlin?
- What is "function*" in JavaScript?
- The "E" and "e" custom specifiers in C#
- What is a "translation unit" in C++
- Difference between "." and "#" selector in CSS
- What is the difference between "profit" and "cash flow from operations"?
- What's the difference between "!!" and "?" in Kotlin?
- Difference between "new operator" and "operator new" in C++?
- What's the difference between "STL" and "C++ Standard Library"?
- What is "namespace" keyword in PHP?
- What is "out" keyword in Kotlin?
Advertisements