lundi 14 août 2017

Why are begin(container) and end(container) accessible everywhere but aren't in global namespace? [duplicate]

This question already has an answer here:

I can do

std::vector<int> v;
begin(v);

yet, when I do

std::vector<int> v;
::begin(v);

I get

error: ‘::begin’ has not been declared ::begin(v);

It works again if I put

using namespace std;

at the top of the file, which I find weird, because I thought doing ::begin would actively prevent it from using std::begin. What is happening here?

Aucun commentaire:

Enregistrer un commentaire