A data type consisting of a set of named values called elements, members or enumerators of the type.
13
votes
3answers
15k views
Conversion between enum and string in C++ class header
I have the following redundant-feeling design to convert between enums and strings regarding a class that stores enums. The ...
3
votes
1answer
153 views
Genericizing PropertyValues
This should be the last iteration for this code.
Does this approach make sense or am I heading down the wrong path?
The only thing I can see to make this better is to genericize the ...
44
votes
15answers
3k views
BOOL×BOOL→ENUM mapping
Does this part look clean enough? Any suggestions on how to make it cleaner?
...
1
vote
0answers
376 views
Enum Design Pattern [closed]
I need criticism/suggestions on a suitable way of controlling many states of display in a GUI like method, "GUIMethod", below.
...
14
votes
1answer
16k views
Getting the value of a custom attribute from an enum
Suppose we have an enum called "Planet" and it has a custom attribute of class "PlanetAttr",
these methods will give you the attribute value for a given Planet value:
...
18
votes
5answers
3k views
Boolean enums: improved clarity or just overkill? [closed]
Suppose we are writing a GUI toolkit in C++ (though this question may also apply to other languages). We have a button class with a member function hide, which ...
5
votes
1answer
977 views
Iterable enum class in C++11
For a small project I'm working on, I've been looking for an iterable enum-like class in C++, since neither C-style nor scoped ...
3
votes
2answers
3k views
Boolean flags encoded as integer implemented with EnumSet
I'm a beginner in Java so I would appreciate a review of following simple class - in fact it's my first real usage of enums.
The background: I'm parsing MySQL internal client-server protocol. One of ...
11
votes
5answers
2k views
8
votes
1answer
214 views
Too much fun with EnumMap-related features and lambdas?
I have created an utilities class to handle certain EnumMap-related features, such as creating and converting between ...
7
votes
2answers
85 views
Validating multiple keys in the builder class based on the rules
I recently started using Builder pattern in one of my projects and I am trying to add some sort of validations on my Builder class. I have already asked a question, got some feedback and incorporated ...
7
votes
4answers
605 views
Tic-Tac-Toe design
Kindly look at this code and point out design flaws or areas for improvement. I think I've done the last part right (the enum). I think the rest of the design is flawed but I am very new to ...
6
votes
0answers
338 views
Building a good C++11 template library - compile-time checked enum array
The task is to add data or values to members of a given enum class. The compiler should check, if a value for each enum member is available, and not just default construct empty values. It is a tool ...
5
votes
1answer
124 views
Enumerating a boolean in C
This is one way to make a boolean in C.
typedef enum {
false = 1 == 0,
true = 0 == 0
} bool;
Recently I made some like
...
2
votes
1answer
64 views
Enum list to STL container
Can someone improve upon this function of mine? EnumToSTLContainer is supposed to make a copy of any STL container whose elements are from a specified ...