Boost logo

Boost :

Subject: Re: [boost] Is there interest in a library for string-convertible enums?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2014-10-29 17:47:18


Le 28/10/14 12:09, Felix Uhl a écrit :
> 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?
>
>

Hi,

inn case you are interested

http://htmlpreview.github.io/?https://github.com/viboes/enums/blob/master/libs/enums/doc/html/index.html

Best,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk