enums Questions

0

C++17 allows scoped enums to be initialized with integers as long as it's not narrowing, e.g. #include <cstdint> enum class e16 : uint16_t { x16, y16 }; enum class e32 : uint32_t { x32, y32 }...
Andria asked 23/10 at 23:35

1

I know that, generally, we can forward-declare enums in C++11. So, why does this: enum kind_t { kind1, kind2 }; template <kind_t Kind> struct foo {}; template <> struct foo<kind1&g...
Dobbs asked 24/8, 2022 at 21:22

2

Solved

I have the unfortunate task in 2024 of adding some code to a codebase that needs to be used in a C++03 setting - where unfortunately the original class myclass can't be changed. I've gotten stuck o...
Hanshaw asked 11/9 at 9:44

5

Solved

An associate has created a schema that uses an ENUM() column for the primary key on a lookup table. The table turns a product code "FB" into it's name "Foo Bar". This primary key is then used as a...
Celanese asked 16/2, 2009 at 3:2

3

Solved

I would like to pass in the parameters what arm of the enum I need to match, something like this: enum D { A(i64), B(u64), C(u64, u64), } let a = D.A(10); println!(a.is_of(D.A)); // true prin...
Forerun asked 23/7, 2019 at 19:45

3

This is my first time working with jest. I have a scenario where I want to see if the selected value is in an enum or not. Here is my test case: test('Should be valid', () => { expect(TestCase...
Perbunan asked 13/9, 2022 at 4:9

5

Solved

I have an enum FileType public static enum FileType { CSV, XML, XLS, TXT, FIXED_LENGTH } FileType fileType = FileType.CSV; Is there a better (cleaner) way to check fileType for multiple values...
Ferret asked 27/11, 2014 at 14:25

4

Solved

I have basic enum enum Fruit { case APPLE; case ORANGE; case BANANA; } and some function that uses typing with that enum: function eatFruit (Fruit $fruit) { // do stuff } and variable with un...
Popelka asked 9/1, 2022 at 20:25

2

Solved

Making an enum with exactly n many members is trivial if I've defined it myself: class Compass(enum.Enum): NORTH = enum.auto() EAST = enum.auto() SOUTH = enum.auto() WEST = enum.auto() ## or #...
Phono asked 5/8 at 23:47

2

I am programming in C for a microcontroller so I am not sure if this question belongs here or on the electronics stackexchange. Just let me know if it doesn't fit here and I will move the question ...
Teleview asked 4/6, 2020 at 12:46

6

Solved

I would like to be able to arrange the ordering of Enum. Has somebody suggestions how this can be solved? The following Enum meta class is using: class EnumMeta(type): def __new__(typ, name, b...
Latex asked 23/8, 2013 at 9:18

3

Solved

Python now has an Enum type (new in 3.4 with PEP 435, and alse backported), and while namespaces are a good thing, sometimes Enums are used more like constants, and the enum members should live in ...
Sporocyte asked 24/1, 2015 at 21:54

5

Solved

Lets's say I have an enumerator, is it possible to get the property that follows? So if I had today=Days.Sunday would I be able to do something like tomorrow=today.next()? example: class Days(Enu...
Ideation asked 26/10, 2014 at 20:32

15

Solved

I have created the following Enum: from enum import Enum class Action(str, Enum): NEW_CUSTOMER = "new_customer" LOGIN = "login" BLOCK = "block" I have inherited f...
Presa asked 10/8, 2020 at 7:21

9

I declare a model with an enum type like: class Event < ActiveRecord::Base enum event_type: { "special_event" => 0, "pto" => 1, "hospitality" => 2, "classroom" => 3 } Then in...
Careful asked 14/8, 2014 at 21:4

4

I'm working on code bases with extensive type hints, checked by mypy. There's several instances where we have a mapping from an enum.Enum or other small finite set of statically known values (typin...
Sinister asked 27/4, 2022 at 1:49

3

What arithmetic operations are supported on c# enums? Surprisingly, I was unable to find it via neither google, nor wikipedia and stackoverflow. Can I add two enum values without any cast? Add arb...
Aryl asked 20/3, 2012 at 9:16

0

While investigating the memory use of an application that exchanges message through PyZMQ using tracemalloc, I noticed a weird behavior of pickling and unpickling enums: memory looks like it is lea...
Diffusion asked 28/6 at 12:40

6

I have a table that contains an enum field CREATE TABLE `user_status` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `values` enum('on', 'off'), PRIMARY KEY (`id`), ) ENGINE=InnoDB; how can...
Woodcut asked 19/2, 2014 at 5:46

4

Solved

Why i can't use reinterpret_cast operator for such a cast? enum Foo { bar, baz }; void foo(Foo) { } int main() { // foo(0); // error: invalid conversion from 'int' to 'Foo' // foo(reinterpret_...
Ingather asked 1/9, 2012 at 14:26

3

Solved

In my code, I was puzzled by Enum instances with the same value not comparing equal. I quickly realized that their id(...) were different. Later, much less quickly, I realized that the only change ...
Clockwork asked 2/11, 2016 at 1:59

12

Solved

I have an enum Nationality: class Nationality: Poland='PL' Germany='DE' France='FR' How can I convert this some enum to int in this or similar way: position_of_enum = int(Nationality.Poland...
Smokechaser asked 19/5, 2011 at 14:57

5

Solved

I would like to populate a java.swing JComboBox with values from an Enum. e.g. public enum Mood { HAPPY, SAD, AWESOME; } and have these three values populate a readonly JComboBox. Thanks!
Hypertrophy asked 22/9, 2009 at 9:32

3

Playing around with the record type in C#, it looks like it could be quite useful to build discriminated-union-like data structures, and I'm just wondering if I'm missing some gotchas that I'll reg...
Diaphoresis asked 3/9, 2020 at 13:6

1

Anonymous enums are in common use for defining compile-time-only constants in a compiler-supported fashion (i.e. without resorting to Macros), in C. This is also true for C++ (because even while th...
Remediable asked 13/6 at 12:25

© 2022 - 2024 — McMap. All rights reserved.