Subject: Re: [boost] Is there interest in a library for string-convertible enums?
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2014-10-28 17:10:20
On October 28, 2014 7:09:35 AM EDT, Felix Uhl <felix.uhl_at_[hidden]> wrote:
>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.
As Niall noted, most of us have done that before.
>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.
That sounds interesting. Ease of use and compilation overhead are concerns, of course.
>Currently, I am documenting the first version of the library to make it
>available on the Boost Library Incubator website,
I can hear Robert yelling, "Yes!"
> 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.
That would certainly be useful.
What about enum classes?
(Sent from my portable computation engine)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk