DEV Community

Discussion on: Let's try C++20 | using enum

pgradot profile image
Pierre Gradot Author • Edited on

Just like using namespace std; or using std::cout;, you should you use using enum EnumWithALongName; in a (very) limited scope to avoid conflicts.

From my experience, if everything function / type / constant is in a namespace, has a descriptive name, and you avoid wide scopes, you will almost run into troubles.

And I assume the C++ committee as the same point view since they added using enum xxx to C++20 ;)

Have you experienced some issues?

maresia profile image
Maresia • Edited on

Yes, it has occurred to me to use one function by mistake, imagining it to be another. The result was a code that behaved very strangely and I only noticed that it used the wrong function much later after spending a long time fighting with gdb. Since then I use this extensively and avoid using.

Thread Thread
pgradot profile image
Pierre Gradot Author

I understand your pain...