Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Introduce Using Statement

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
membry Posted - Sep 17 2009 : 4:03:17 PM
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.
3   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Oct 06 2009 : 6:59:26 PM
This makes sense, I have put in a feature request for this:

case=33328
membry Posted - Sep 24 2009 : 3:15:29 PM
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.
feline Posted - Sep 24 2009 : 12:52:04 PM
Do you have much code at stage 1?

I see the appeal of this idea, I am just thinking that limiting it to only stage 2 might be unhelpful for people with code at stage 1.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000