开发者

c++ - enum to char * - This answerless q‌u‌e‌s‌t‌i‌o‌n was asked before the time of boost

I knew that similar duplicate questions are available in SO. But those questions were not discussing that much about boost. I got the type of enum using

(boost::any).type().name()

En开发者_开发百科um Example{ex1,ex2};

The above code will produce

Example

But I want to get the exact phrase like "ex1". I am using VC++ now. There I need to check each and every enum to populate some message about API call's status. I am very new to boost, but now itself I can fell the (flex|a)ibility of the boost. So there must be a easy method which has the ability to do this.

Thanks Prabhakaran(answers){}


Boost has no magical ways of doing this. For types, it can rely on RTTI, a basic C++ feature. But enumerator names are lost once a program is compiled.


Could it be what you are looking for?

Enum to String and Vice Versa in C++ http://www.codeproject.com/KB/cpp/StringizingCppEnums.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜