Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Refactoring: Convert unscoped enum to scoped enum

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
rpalma Posted - Mar 01 2018 : 04:33:10 AM
Hello,

It would be nice to have a refactoring option to convert an unscoped enumeration to a C++11 scoped enumeration, including all its referred enumerators.

As this is something that is done quite frequently in our code base, it would be a handy feature saving us from the tedious task to hunt down all referred enumerators and add their scope manually. A naive search-and-replace is too error prone.

enum Color { red, green, blue };
Color col = red;
switch(col)
{
    case red  : std::cout << "red\n";   break;
    case green: std::cout << "green\n"; break;
    case blue : std::cout << "blue\n";  break;
}

After refactoring becomes:
enum class Color { red, green, blue };
Color col = Color::red;
switch(col)
{
    case Color::red  : std::cout << "red\n";   break;
    case Color::green: std::cout << "green\n"; break;
    case Color::blue : std::cout << "blue\n";  break;
}
2   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Dec 20 2019 : 2:24:24 PM
case=93116 is implemented in build 2358
https://support.wholetomato.com/default.asp?W404
http://builds.wholetomato.com/binaries/VA_X_Setup2358_0.exe
feline Posted - Mar 01 2018 : 07:46:04 AM
We are considering adding a refactoring to convert a normal enum to a strong enum class, which will also update all of the enum item instances like this:

case=93116

For now, if you know which functions the enum items are being used in, you may find VA's Smart Select commands helpful, since this will let you quickly and easily select the entire function body, so you can do a search and replace just on the selected text, keeping the scope limited and thus more accurate:

https://support.wholetomato.com/default.asp?W560

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