Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 refactor help with adding/using namespaces

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
peterchen Posted - Sep 26 2014 : 08:40:31 AM
given

// bar.h
namespace Foo
{
   struct Bar {}
}

// bar.cpp
Bar b;

The refactor menu for Bar (in bar.cpp) offers to "include bar.h". This usually works well.

However, it does not help with adding the required namespace.

The following suggestions would be nice:

  • add "Foo::" to the declaration (resulting in Foo::Bar b;)

  • add "using namespace Foo" to current scope, current function or current file

  • add "using Foo::Bar" to one of these scopes


Thinking about it, there are pretty many options how to resolve this, I'm not quite sure how to present them, maybe "add to current scope" is not that very and could be omitted.

Of course, "using namespace..." should not be suggested in a header file, and "add to current scope" can be omitted if the current scope is the function (or file).
3   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Oct 08 2014 : 7:11:04 PM
Apologies for the slow reply. This makes sense, and adding a using namespace line to help where required is something we are considering, so I have added the thoughts from here to the case:

case=32045
peterchen Posted - Sep 30 2014 : 09:59:05 AM
I would probably opt for "function level" most of the time - I personally find that preferrable if only only one or two functions (out of dozens) are affected.

At file level if the majority of functions would have that using statement, e.g. a UI class pulling in UI ultilities.

Anyway, even with "using statement at file level" and "change declaration to include namespace", this would be a very valuable feature - changing the using statement to be more local is a bit rote but easy to do.
feline Posted - Sep 26 2014 : 3:18:00 PM
Which method do you tend to use in your code? From the code samples I see, adding "using namespace Foo" to the file, so effecting the entire file, seems a fairly common method. This has the advantage of giving you a using statement you can easily cut and paste if you want to place it somewhere else, narrowing its scope.

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