Why in c++, when I invoke std::sort
, I have no error (even no warning) if I forget the namespace?
You can try with:
#include <algorithm>
#include <vector>
int main () {
int init[] = {17,42,51,27,36,72,11,25};
std::vector<int> myvector(init, init+8);
sort(myvector.begin(), myvector.end()); //instead of std::sort
return 0;
}
and then compile with:
g++ test.cpp -o test -Wall -Wextra -std=c++11
(Tested with g++ 4.9)