Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6843067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:12:05+00:00 2026-05-27T00:12:05+00:00

I know that it’s possible to write a register macro that will map their

  • 0

I know that it’s possible to write a “register” macro that will map their values to their string representations. Is there however some new magic in C++11 that makes it possible to do without macros and any registration boilerplate?

To make it clear, I would like to be able to print the identifiers of enum variables, such as:

enum Days { Sunday, Monday, Tuesday };
auto d = Days::Sunday;
std::cout << magic << d;

Should output

Days::Sunday
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:12:06+00:00Added an answer on May 27, 2026 at 12:12 am

    No, this is not really possible. You need macros (preferably) or to extend the compiler for additional tricks (you might extend GCC with plugins or with MELT to provide a special _my_enum_name_builtin function, but I don’t think it is a good idea). You could also (assuming the executable is built with debugging information kept) extract the name from debugging information.

    If you really need that, a perhaps simpler way is to generate some (C++) code, which is nearly what macros are doing for you. The Qt Moc could be an inspiration for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that if you write void function_name(int& a) , then the function will
I know that you can insert multiple rows at once, is there a way
I know that |DataDirectory| will resolve to App_Data in an ASP.NET application but is
I know that the MsNLB can be configured to user mulitcast with IGMP. However,
I know that there are functions in the objective-c runtime that allow you to
I know that in the google maps API it's possible to replace the existing
I know that Visual Studio under debugging options will fill memory with a known
I know that there are more than a dozen questions about this. But I
I know that there are lots of posts about memory leaks. Now i am
I know that this may be common knowledge, but is there a way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.