I'm surprised that this simple program compiles:
#include <vector>
#include <stdio.h>
int main()
{
std::vector<int> v = {1,2,3};
auto x = v.end();
if (x == end(v)) // << == end used without `std::`
printf("v.end == end(v)\n");
}
On one of the lines, std::end
is used without specifying std::
namespace. Surprisingly, this compiles even though there is no using namespace std
. What's going on, why does it compile without any errors/warnings?
https://godbolt.org/z/7e9xMh361 (compiles with gcc/clang/msvc)