Why is std::begin accessible unqualifiedly when I include vector?

55 Views Asked by At

I thought that I always need the std:: qualification for std::something, unless I'm using std::something or the whole namespace std, but it seems that #include <vector> makes, for instance, std::begin availble as begin.

Why is this the case?

#include <vector>
int main(){
    int w[3];
    begin(w); // Ok, this doesn't compile, as I'm not `using std::begin` nor `using namespace std`.
    std::vector<int> v;
    v.begin(); // Ok, as this is the member function.
    begin(v); // Why does this compile? What is making this free-function available unqualifiedly?
}
0

There are 0 best solutions below