|
Boost : |
Subject: Re: [boost] Is there interest in a library for string-convertible enums?
From: Pieter (PieterB_at_[hidden])
Date: 2014-10-29 07:30:42
Hi Felix,
Are you aware of the earlier effort by Frank Laub? Once there was a boost.enum library (v4.6) in the boost Sandbox, but I think it can no longer be found (I contacted the author in 2011 and not even he could find it then!). It is also based on Boost.Preprocessor to generate most of the code. Obviously, it never made it into boost.
I am currently using a version of this library that I adapted quite significantly to make it meet my own needs. I would be curious how your library would compare to this previous effort and I'd be happy to send you more information if you don't have it.
Pieter
-----Original Message-----
From: Felix Uhl [mailto:felix.uhl_at_[hidden]]
Sent: Tuesday, October 28, 2014 12:10 PM
To: boost_at_[hidden]
Subject: [boost] Is there interest in a library for string-convertible enums?
So far, the only way to convert an enumeration value to a string is a lot of boilerplate code consisting of switch case statements for every single possible value of the enum.
Iâve written a small header-only library that uses Boost.Preprocessor and templates to ease the definition of named enumerations that are convertible to and from strings. Those can also be used with the std::cin and std::cout streams naturally, while maintaining all syntactic and semantic properties, regarding initialisation, assignment, type safety and conversion to underlying types.
Currently, I am documenting the first version of the library to make it available on the Boost Library Incubator website, but I wanted to get some initial feedback from the developers mailing list, too. I would be glad to extend the library to a general extension of enumeration behaviour, like changing the generation of underlying values from a continuous increment to a continuous shift left by one, effectively making the underlying values binary flags.
What features would you want from such a library? Is there even a chance that such a library would get included in boost (given that it satisfied the quality requirements), or is there too little interest in this functionality?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk