Skip to main content
Filter by
Sorted by
Tagged with
5 votes
2 answers
2k views

How do I get an enum from a boost::property_tree? This is my "non-working" example. config.xml <root> <fooEnum>EMISSION::EMIT1</fooEnum> <fooDouble>42</fooDouble> ...
Raymond Valdes's user avatar
1 vote
1 answer
800 views

How do you read a enum-class from an XML file using the boost::property_tree library? I would like to avoid reading it as a string and mapping the string to the enum-class in my program.
Raymond Valdes's user avatar
59 votes
1 answer
19k views

I have the following enum specification: enum class FaceDirection : int8 { Down, Up }; g++ 4.8.1 gives the following error: warning: elaborated-type-specifier for a scoped enum must not use the ...
Drew Noakes's user avatar
2 votes
3 answers
1k views

it seems there are some problems with my g++ 4.2 compiler in my Mac. I defined a enum class as follows. enum class Suit {CLUBS,SPADES,HEARTS,DIAMONDS}; It can compile and run in VS2013 but failed to ...
ivory's user avatar
  • 263
19 votes
3 answers
4k views

I've seen reinterpret_cast used to apply incrementation to enum classes, and I'd like to know if this usage is acceptable in standard C++. enum class Foo : int8_t { Bar1, Bar2, Bar3, ...
GOTO 0's user avatar
  • 48.8k
21 votes
1 answer
30k views

In State.h I have enum class StateID : unsigned int; In State.cpp I have enum class StateID : unsigned int { NullID = 0, MainMenuID, GamePlayID, }; The problem is that any class that ...
EddieV223's user avatar
  • 5,373
98 votes
8 answers
69k views

I have a class containing an enum class. class Shader { public: enum class Type { Vertex = GL_VERTEX_SHADER, Geometry = GL_GEOMETRY_SHADER, Fragment = GL_FRAGMENT_SHADER ...
Appleshell's user avatar
  • 7,438
10 votes
1 answer
4k views

I usually use enum with the 'bit-or' or | together to allow an object has some options. How to make enum class to work with the 'bit-or' feature?
user1899020's user avatar
  • 13.6k
2 votes
1 answer
1k views

I have an old C library and I have to wrap it inside a C++ environment. I use C++11 enum class because they're so useful and I'd like to do transform the original enum into a new enum class without ...
user2714602's user avatar
768 votes
9 answers
553k views

I heard a few people recommending to use enum classes in C++ because of their type safety. But what does that really mean?
Oleksiy's user avatar
  • 40.3k
5 votes
2 answers
6k views

I have an enum like this: (Actually, it's an enum class) enum class truth_enum { my_true = 1, my_false = 0 }; I would like to be able to expose my_true to the global namespace, so that I can ...
user2138149's user avatar
  • 18.7k
47 votes
3 answers
52k views

Is there a way to specify the default constructor of an enum class? I am using an enum class to specify a set of values which are allowable for a particular datatype in a library: in this case, it's ...
FizzixNerd's user avatar
11 votes
2 answers
6k views

I have basically two questions may be they are related so I'll put them into one. Should we pass enum class in C++11 by reference or value when passing to function. It is sort of inheriting primitive ...
Majid Q.'s user avatar
  • 808
9 votes
1 answer
9k views

First of all I want a normal enumeration instead of a bit-based enumeration, because the amount of different enums will be beyond any integral type. I also want to take advantage of the type safety of ...
Kornel Kisielewicz's user avatar
0 votes
2 answers
469 views

Given a C++11 enum class, is there some templating or other construct to iterate, at compile-time, over the set of all enumerators? Could one define a template to e.g. initialize an array with all ...
MvG's user avatar
  • 61.8k
6 votes
1 answer
3k views

I've recently started working the C++/CLI managed code, but I've always defined enums like so: enum FV_MODE { IDLE,DRAG,ADD_HITBOX,ADD_HURTBOX }; Until today, when I was hit with the error ...
Guy Joel McLean's user avatar
1 vote
0 answers
347 views

Consider the following code, which compiles fine in clang but not in gcc (4.7.2): template<typename T> using remove_ref_typed = typename std::remove_reference<T>::type; // alias-...
etherice's user avatar
  • 1,821
44 votes
3 answers
117k views

Following the discussion in question Incrementation and decrementation of “enum class”, I'd like to ask about the possible implementation of arithmetic operators for enum class types. Example from ...
SomeWittyUsername's user avatar
5 votes
1 answer
2k views

My usage of enum class (VS2012): class matrix { public: enum class operation_type {ADD, MULT}; matrix(operation_type op); ... } and in another fragment I use matrix* m = new matrix(matrix::...
Joshua MN's user avatar
  • 1,536
8 votes
6 answers
24k views

Can this be done? enum A { enum B { SOMETHING1, SOMETHING2 }; enum C { SOMETHING3, SOMETHING4 }; }; If not is there an alternative solution? ...
user2138149's user avatar
  • 18.7k
134 votes
19 answers
126k views

Is it possible to determine the cardinality of a c++ enum class: enum class Example { A, B, C, D, E }; I tried to use sizeof, however, it returns the size of an enum element. sizeof(Example); // ...
bquenin's user avatar
  • 1,610
16 votes
2 answers
29k views

I have an enum class like this: typedef unsigned int binary_instructions_t; enum class BinaryInstructions : binary_instructions_t { END_INSTRUCTION = 0x0, RESET, ...
user2138149's user avatar
  • 18.7k
5 votes
2 answers
265 views

A compiler error occurs when I try to compile the following code: for(binary_instructions_t &inst: BinaryInstructions){ } BinaryInstructions is this enum class: typedef unsigned int ...
user2138149's user avatar
  • 18.7k
1 vote
1 answer
216 views

Is the type enum class a completely separate from a traditional class, or is its implementation similar? How does enum class work? The reason I ask is because I don't understand how it can be similar ...
user2138149's user avatar
  • 18.7k
4 votes
2 answers
3k views

I used the new C++11 "enum class" type and observed a "undefined reference" problem when using g++. This probleme does not happen with clang++. I do not know if I am doing something wrong or if it is ...
Picaud Vincent's user avatar
1 vote
2 answers
370 views

I'm a newbie to C++ and especially C++11, so since I've now got to use it, a few questions about 'enum' and 'enum class' came up: Can I assign values after the enumeration has been declared? enum ...
Xaymar's user avatar
  • 87
5 votes
2 answers
2k views

In my project I have a lot of enumerations that need to have additional attributes associated with the enumeration members and auxiliary static methods associated with the enumeration type. As much ...
David L.'s user avatar
  • 3,329
8 votes
4 answers
6k views

For one who has never written a line of C++11, and who has, at the moment, no opportunity to program in C++11, can you, in one short paragraph., tell me: What is an "enum class" and why do we need ...
sbi's user avatar
  • 225k
2 votes
2 answers
759 views

I had enum class, say enum class Enum{ var1, var2; } Now I want to add some member which depends on parameter i.e var3(int). OK, It's not for enum, so I want to change it by regular class, but my ...
RiaD's user avatar
  • 47.8k
1 vote
0 answers
23 views

I use Stanford POStagger and I want to define an enum as bellow : public enum POSType { CC("Conjunction"), CD("Number"), ! ("Punctuation") ...... } How can I define a ...
Mona's user avatar
  • 11
4 votes
1 answer
3k views

I've encountered the following form of enum class variable instantiation and it is compiling without any warning or error under VS2012: UINT32 id; enum class X {apple, pear, orange}; X myX = X(id); ...
SomeWittyUsername's user avatar
57 votes
3 answers
23k views

Normally you can define a cast for a class by using the following syntax: class Test { public: explicit operator bool() { return false; } }; Is there a way to do this or something similar for an ...
OmnipotentEntity's user avatar
-1 votes
1 answer
172 views

I have declared an enum as follows: enum fileType {typeA, typeB}; This is causing an error when I try to append directoryType type to a string. I believe I need to include the underlying type of the ...
Ocasta Eshu's user avatar
43 votes
5 answers
39k views

Can you implement standard conformant (as described in 17.5.2.1.3 of the n3242 draft) type safe bitmasks using enum class? The way I read it, a type T is a bitmask if it supports the |,&,^,~,|=,&...
SomeoneWithQuestions's user avatar
4 votes
1 answer
256 views

I created small class that allows me to use enumerators of strongly-typed enums as flags (in combination). I'm using type_traits for underlying type detection so it should be also slightly type safe ...
HemoGoblin's user avatar
148 votes
10 answers
214k views

How can I output the value of an enum class in C++11? In C++03 it's like this: #include <iostream> using namespace std; enum A { a = 1, b = 69, c= 666 }; int main () { A a = A::c; ...
Adi's user avatar
  • 2,091
14 votes
7 answers
13k views

I'm using a std::tuple and defined a class enum to somehow "naming" each of the tuple's fields, forgetting about their actual indexes. So instead of doing this: std::tuple<A,B> tup; /* ... */ ...
mfontanini's user avatar
7 votes
2 answers
979 views

Suppose there is a C++11 API that uses enum classes: // api.hpp enum class E {A, B, C}; void f(E); ... // api.cpp void f(E e) { if (e == E::A) ... } Now suppose I would like to use this ...
HighCommander4's user avatar
9 votes
3 answers
5k views

i have some enum class enum class Foo { A=1, B=18 , Z=42 }; i want to check if some integer can be converted into a Foo. What would be the ideal way to do this? this is for runtime check (the ...
lurscher's user avatar
  • 27.2k
9 votes
3 answers
934 views

C++11 adds enum classes, which are stronger-typed enums - values of enum classes will not be implicitly converted to values of other enum classes or integers, and forward-declarations are permitted by ...
user avatar
8 votes
1 answer
3k views

why aren't instances of strongly typed C++0x enumerations comparable to each other? Update: They are comparable in gcc 4.6; I'm not sure if it worked in gcc 4.4.
Neil G's user avatar
  • 33.6k

1 2 3
4