Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost Python enum_ max value issues

enum MyEnum
{
    SOME_NAME = 2147483648;
};

...

enum_<MyEnum>("MyEnum")
    .value("SOME_NAME", SOME_NAME)
;

While this compile fine, it crashes on initialization cause enum_ is casting values as "long" which is limited to 2147483647. I'd need them to be unsigned long. Is there any way to do that without having to create an entire enum wrapper?

Thanks!

like image 722
John Smith Avatar asked Nov 11 '22 09:11

John Smith


1 Answers

C++ allows you to implicitly cast an enum to an int, not an unsigned int. You're capped to INT_MAX as the maximum value. Furthermore, you have to cast an int (or an unsigned int that becomes sign-converted) to convert it back to an enum.

like image 165
scooter me fecit Avatar answered Nov 15 '22 08:11

scooter me fecit