Boost logo

Boost :

Subject: Re: [boost] enum / string translation
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-07-22 09:12:19

On Wed, Jul 22, 2009 at 12:33 AM, Ross Levine<ross.levine_at_[hidden]> wrote:
> How is this different from using a std::map and boost::assign's map_list_of?

Internally it uses an std::map for the runtime lookup, so in that
sense maybe not much. But using an std::map won't allow you to do
compile-time enum value->string translation. I was also trying to
minimize the number of times you had to refer to a single enum value
v, so that for example you didn't have to do 2 separate declarations
for a compile-time lookup and a runtime lookup. So if you use
map_list_of that will give you a runtime lookup and then I think
you'll need to respecify all the values using some other mechanism if
you additionally want a compile-time lookup. It might be possible to
do compile time string->enum translation as well, I know some work was
done on an mpl::string, but admittedly I'm still an mpl novice and I
didn't look into it.

Boost list run by bdawes at, gregod at, cpdaniel at, john at