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 6594149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:46:24+00:00 2026-05-25T17:46:24+00:00

It was posted on this site how you could generate unique enum constants by

  • 0

It was posted on this site how you could generate unique enum constants by doing the following:

enum _EXAMPLE
{
    LEFT = 'left',
    RIGHT = 'right'
    //etc
};

Ignoring the issue of validity, how are the numbers generated? More specifically, what technique is used? As I wish to try to build a function that emulates it for short strings.

  • 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-25T17:46:25+00:00Added an answer on May 25, 2026 at 5:46 pm

    'left' is a multicharacter literal (2.13.2/1 of C++03), it has type int.

    It’s implementation-defined what integer value it actually has. In particular, there’s no guarantee that 'left' and 'right' aren’t equal, so you’re on to something of a loser using them in an enum.

    For an example, though, GCC documents its behavior here: http://gcc.gnu.org/onlinedocs/gcc-4.6.1/cpp/Implementation_002ddefined-behavior.html#Implementation_002ddefined-behavior

    'right' has five characters, and clearly it’s not possible for every 5-character string to have a different 32 bit value.

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

Sidebar

Related Questions

This question was posted on some site. I didnt find right answers there, so
I have an sql statement that I posted on this site, and I applied
This question could be posted on ServerFault as well, however there is definitely a
Already posted this in Google Analytics help forum, but noone could help. Hopefully I
I posted this question yesterday evening, which has led me to discover a huge
I posted this question: https://stackoverflow.com/questions/418597/java-and-net-for-php-programmer and the answers I was given didn't really help
I posted this question on Reddit Programming and did not get a single response.
I posted this very same item on SERVERFAULT, but got no reply. So here
I posted this back in May on the [android-developers] Google Group. I never heard
LearnWPF.com posted this article about converting bitmap images to XAML and using them in

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.