Re: [Boost-users] safe assign of int to enum

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Tim Robertson Sent: Monday, March 27, 2006 3:46 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] safe assign of int to enum
I've wasted many hours doing most of these things, so I would be interested in seeing your solution.
At the very least, could you post some information on the approach you used to keep the forward/reverse mappings updated automatically? Also, were you able to do all of this without balooning the size of your "enums"? I've never found a way to do that....
You make a good point. We should want sizeof(other_enum)==sizeof(c_enum). Not everyone needs to map between strings and enumerations

You make a good point. We should want sizeof(other_enum)==sizeof(c_enum). Not everyone needs to map between strings and enumerations
While I can't guarantee that, that is the case most of the time. Put it this way - it will be true if your compiler will take a structure with one member and no virtual functions and make sizeof(structure)==sizeof(member). I think I will add a feature to allow the programmer to specify the underlying enum size, too (i.e. int, long, etc.) As I said, the implementation is both space and time efficient. Tom

FYI: Some googling tells me that there is current work underway (since 2002?) on a Boost enum library. Go here for a tarball of the latest candidate: http://boost-consulting.com/vault/index.php? action=downloadfile&filename=enum_rev4.6.zip&directory=&PHPSESSID=aae83f bb6983e99c3a7b00c813f10502&PHPSESSID=aae83fbb6983e99c3a7b00c813f10502 -tim On Mar 27, 2006, at 5:52 PM, Tomas Puverle wrote:
You make a good point. We should want sizeof(other_enum)==sizeof(c_enum). Not everyone needs to map between strings and enumerations
While I can't guarantee that, that is the case most of the time. Put it this way - it will be true if your compiler will take a structure with one member and no virtual functions and make sizeof(structure)==sizeof(member). I think I will add a feature to allow the programmer to specify the underlying enum size, too (i.e. int, long, etc.) As I said, the implementation is both space and time efficient.
Tom
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Sohail Somani
-
Tim Robertson
-
Tomas Puverle