Is there a way to not use an item from a namespace?

You cannot do that (include everything and then selectively exclude something).

Your options are:

1) always explicitly qualify names. Like std::vector<int> v;

2) pull in all names with using namespace std;

3) pull in just the names you need with, for example, using std::vector; and then do vector<int> v; - names other than "vector" are not pulled in.

Note: using namespace std; doesn't have to go at global scope and pollute the entire file. You can do it inside a function if you want:

void f() {
    using namespace std;
    // More code
}

That way, only f() pulls in all names in its local scope. Same goes for using std::vector; etc.


You can using ns_name::name; just the name's you want unqualified access to.

https://en.cppreference.com/w/cpp/language/namespace