One of the challenges of working on a large legacy C++ project is the overuse of "using namespace <foo>". Along with the consequences thereof.
(1) To go from:
using namespace std;
string text = "refactor me...";
(2) to:
std::string text = "refactor me...";
(3) to:
using std::string;
string text = "refactor me...";
should be a valid C++ refactoring (more so for source files than header files but still valid).
It would be helpful if VAX had a "Introduce Using Statement" refactoring similar to the "Add Include" refactoring where VAX would go from step 2 to step 3 above. I'd prefer that the using statements be added just below includes. Per Sutter et al C++ Coding Standards book.
FWIW, We did consider leaving everything at (2) for source files but some of the namespaces tend to have long names, Google Mock seemingly has a namespace for every other line of their code and boost overloads a lot of operators for which it is cleaner and less confusing to use a using statement anyway.
Our large legacy C++ is currently a mix of stage 2 and stage 3. Hench the request. Never thought of automating stage 1 to stage 2. Good idea. But many-to-one is a concern. Maybe just prepend the namespace and leave it to the user to remove the using namespace statement? We just used text search-and-replace, including some comments. Heh. But that was the quickest way to get around some include dependency problems and we were planning on getting rid of most using namespace statements anyway. Now we just manually convert from stage 2 to stage 3 as we refactor and it would be nice if VAX could help with that.