Subject: Re: [boost] Is there interest in a library for string-convertible enums?
From: Artyom Tokmakov (artyom.tokmakov_at_[hidden])
Date: 2014-10-29 18:46:36
> And thatâs where the problem lies. To enable large numbers of enum values,
> Iâd have to find a solution without using Boost.PP. Without C++ introducing
> argument number based macro overloading, that is not possible, short of
> defining my own macro sequences for more than 256 elements, which I would like to avoid.
I wonder, how many people are out there who want to go beyond 256 :)
Have you considered X-macro trick (say, here:
That definitely doesn't have those limitations, looks simple enough
(although not as neat as Boost.Preprocessor), and also allows you to
generate many things out of it.
Just now tested it with 500 enum elements:
#define MYENUM \
enum class MyEnum
#define X(EnumVal_) EnumVal_,
const char* ToString(MyEnum e)
#define X(EnumVal_) case MyEnum::EnumVal_: return #EnumVal_;
std::cout << ToString(MyEnum::Val102) << std::endl;
std::cout << ToString(MyEnum::Val500) << std::endl;
-- Best regards, Artem Tokmakov
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk