Argument dependent lookup

Argument-dependent lookup, also known as ADL, or Koenig lookup [1], is the set of rules for looking up the unqualified function names in function-call expressions, including implicit function calls to overloaded operators. These 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.

See ADL.

Why does this compile?

A one-liner to print a vector to stdout. But why does this compile without the namespace std::?

#include <iostream>
#include <vector>
#include <iterator>

int main() {

    const std::vector<int> v{1, 2, 3, 4, 5};
    copy(cbegin(v), cend(v), std::ostream_iterator<int>(std::cout, "n"));
}

Run the code on Compiler Explorer, Jason Turner on YouTube and ADL on Wikipedia. Note: C++14 is the default for the latest GCC (9.2).

results matching ""

    No results matching ""